<template>
  <div class="page-common-layout">
    <div class="page-common-content">
      <tool-bar
        @search="$refs.table.refresh(true)"
        @reset="
          () => {
            (this.queryParam = {}), $refs.table.refresh(true);
          }
        "
      >
        <template slot="toolBtn" slot-scope="scope">
          <a-button
            class="cu-btn-primary"
            icon="plus"
            @click="handleAdd()"
            v-action:managementAddDialog
            >{{$ct("add","新增")}}</a-button
          >
        </template>
        <template slot="toolForm">
          <a-form-item :label="$ct('name','名称')">
            <a-input v-model="queryParam.buttonName" :placeholder="$ct('name','名称')" />
          </a-form-item>
        </template>
      </tool-bar>
      <DataGrid
        ref="table"
        :columns="columns"
        :url="url"
        rowKey="uuid"
        showPagination="auto"
        :queryParam="queryParam"
        :showRowSelect="false"
      >
        <span slot="renderAction" slot-scope="{ text, record }">
          <template>
            <a @click="handleEdit(record)">{{$ct("edit","编辑")}}</a>
            <span class="action-margin"></span>
            <a @click="handleSub(record)" class="action-delete">{{$ct("delete","删除")}}</a>
          </template>
        </span>
      </DataGrid>
      <edit-form
        ref="createModal"
        :visible="visible"
        :loading="confirmLoading"
        :model="mdl"
        @cancel="handleCancel()"
        @ok="handleOk()"
      />
    </div>
  </div>
</template>

<script>
import { dataGridMixin } from "@/mixins/dataGridMixin";
import { DataGrid } from "@/components";

import editForm from "./add.vue";

export default {
  name: "TableList",
  mixins: [dataGridMixin],
  components: { DataGrid, editForm },
  data() {
    return {
      columns: [
        {
          title: "名称",
          dataIndex: "buttonName",
          align: "center",
          langCode: "name",
        },
        {
          title: "标识",
          dataIndex: "buttonCode",
          align: "center",
          langCode: "identification",
        },
        {
          title: "排序",
          dataIndex: "buttonSort",
          align: "center",
          langCode: "sort",
        },
        {
          title: "操作",
          dataIndex: "action",
          align: "center",
          width: 120,
          scopedSlots: {
            customRender: "renderAction",
          },
        },
      ],
      visible: false,
      confirmLoading: false,
      mdl: null,
      // 查询参数
      queryParam: {},
      url: {
        getPageSet: "/workflow/flowButton/getPageSet",
        deleteBatch: "/workflow/flowButton/deleteBatch",
        update: "/workflow/flowButton/update",
        save: "/workflow/flowButton/save",
      },
    };
  },
};
</script>

<style lang="less"></style>
